#include<bits/stdc++.h>
using namespace std;
typedef struct node{
	char data;
	struct node *lchild,*rchild;
}BTNode;
typedef struct node * BTree;
BTree CreatBT(char *pre,char *in,int n);
int GetHeight(BTree BT);
int main(){
	BTree BT;
	BT=new BTNode;
	int n,i;
	char s[55],t[55];
	scanf("%d%s%s",&n,s,t);
	BT=CreatBT(s,t,n);
	printf("%d\n", GetHeight(BT));
	return 0;
}
BTree CreatBT(char *pre,char *in,int n){
 	BTree s;
	char *p;
	int k;
	if(n<=0) return NULL;
	s=new BTNode;
	s->data=*pre;
	for(p=in;p<in+n;p++){
		if(*p==*pre) {
			break;
		}
	}
	k=p-in;
	s->lchild=CreatBT(pre+1,in,k);
	s->rchild=CreatBT(pre+k+1,p+1,n-k-1);
	return s;
}
int GetHeight( BTree BT ){
	int lchildh,rchildh;
	if(BT==NULL) return 0;
	else {
		lchildh=GetHeight(BT->lchild);
		rchildh=GetHeight(BT->rchild);
		return (lchildh>rchildh)?(lchildh+1):(rchildh+1);
	}
}
